package com.pactera.chat.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.pactera.chat.bean.ChatUser;
import com.pactera.chat.mapper.inf.ChatUserMapper;
import com.pactera.chat.mapper.util.MybatisUtils;

/**
 * @author s-team_zhang
 * @version 1.0 
 */
public class ChatUserDao {
	private SqlSession session;
	
	
	public List<ChatUser> select(ChatUser usr){
		List<ChatUser> usrs = null;
		try {
			session = MybatisUtils.getInstance();
			ChatUserMapper mapper = session.getMapper(ChatUserMapper.class);
			usrs = mapper.select(usr);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(null!= session){
				session.close();
			}
		}
		return usrs;
	}
	
	public ChatUser selectByKey(Integer id){
		ChatUser chatUsr = null;
		try {
			session = MybatisUtils.getInstance();
			ChatUserMapper mapper = session.getMapper(ChatUserMapper.class);
			chatUsr = mapper.selectByKey(id);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(null!= session){
				session.close();
			}
		}
		return chatUsr;
	}
}
